<?php
namespace Admin\Controller;
class AdminController extends BaseController{
	function admin_list(){
		$admin_listOb=M("admin");
		$arr=$admin_listOb->select();
		$this->assign("arr",$arr);	
		$this->display();
	}

	function admin_role(){
		$admin_listOb=M("admin");
		$arr=$admin_listOb->select();
		$this->assign("arr",$arr);				  
		$this->display();
	}

	function admin_update(){
		$admin_updateOb=M("Admin");
		$id=$_GET['id'];

		$arr=$admin_updateOb->where("id=$id")->find();
		
		$this->assign('arr',$arr);
		$this->display();
	}

	function admin_del(){
        $id = $_GET['id'];
        $modelOb = M('admin');
        $re = $modelOb->where("id=$id")->delete();
        if($re){
            echo 1;
        }
    }

    function admin_add(){
    	$mOb=M('Admin');
    	$_POST['regtime']=time();
    	if($_POST['password']==$_POST['password2']){
    		unset($_POST['password2']);
    		$arr=$mOb->data($_POST)->add();
  			if($arr){
  				echo 1;
  			}
    	}
    
    	
    	$this->display();
    }

    function admin_check(){
    	$mOb=M('Admin');
    	// print_r($_POST);
    	// exit();
    	if(!empty($_POST)){
    		if($_POST['password2']!=$_POST['password']){
    			$data['status']==0;
    			$data['info']=="2次密码不一致";
    			$this->ajaxReturn($data);
    			exit();
    		}else{
    			unset($_POST['password2']);
    			var_dump($_POST['id']);
    			exit();
    			$arr=M("Admin")->data($_POST)->save();
    			if($arr){
    			$data['status']==1;
    			$data['info']=="修改成功";
    			$data['url']=U("Admin/Admin/admin_list");
    			$this->ajaxReturn($data);
    		 }
    		}
    		
    	}
    }


}